package com.chk.article.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chk.article.clients.UserClient;
import com.chk.article.entity.User;
import com.chk.article.mapper.ArticleMapper;
import com.chk.article.entity.Article;
import com.chk.article.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * (Article)表服务实现类
 *
 * @author makejava
 * @since 2023-10-20 10:58:49
 */
@Service("articleService")
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements ArticleService {
    @Autowired
    private UserClient userClient;
    @Autowired
    private ArticleMapper articleMapper;
    @Override
    public Article getArticleById(Integer articleId) {
        Article article = articleMapper.selectById(articleId);
        User user = userClient.getUserById(article.getAuthorId());
        article.setUser(user);
        return article;
    }
}

